package com.xspace.android.imcommon.interfaces;

import android.os.RemoteException;

import com.xspace.android.imcommon.entity.Friend;

public class FriendMg {
	private ServiceManager mServiceManager = null;

	private FriendMg() {
		mServiceManager = ImServiceConnection.getInstance().getImServiceConnection();
	}

	private static FriendMg instance = null;

	public static FriendMg getInstance() {
		if (null == instance) {
			instance = new FriendMg();
		}
		return instance;
	}

	public void queryFriendInfo(String owner, String userId, IFriendListener mIFriendListener) {
		try {
			mServiceManager.queryFriendInfo(owner, userId, mIFriendListener);
		} catch (RemoteException e) {
			e.printStackTrace();
		}

	}

	public void queryFriendMsgList(final String userId, final IFriendListener mIFriendListener) {
		try {
			mServiceManager.queryFriendMsgList(userId, mIFriendListener);
		} catch (RemoteException e) {
			e.printStackTrace();
		}

	}

	public void saveOrUpdateFriend(Friend info, String owner) {
		try {
			mServiceManager.saveOrUpdateFriend(info, owner);
		} catch (RemoteException e) {
			e.printStackTrace();
		}

	}

	
	public boolean addFriend(String mBarejid, String mName, String mMobile) {
		try {
			return mServiceManager.addFriend(mBarejid, mName, mMobile);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}

	}
	public void getServerFriendList() {
		try {
			 mServiceManager.getServerFriendList();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	public boolean deleteFriend(String mBarejid) {
		try {
			return mServiceManager.deleteFriend(mBarejid);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}

	}

}